home *** CD-ROM | disk | FTP | other *** search
/ Enter 2006 February / enter-2006-02.iso / files / Illustrator_CS2_ue_TryOut.exe / bridge / Adobe Bridge 1.0.msi / Data1.cab / ols.jsx < prev    next >
Encoding:
Text File  |  2005-03-24  |  28.5 KB  |  907 lines

  1. /*************************************************************************
  2. *
  3. * ADOBE CONFIDENTIAL
  4. * ___________________
  5. *
  6. *  Copyright 2004 Adobe Systems Incorporated
  7. *  All Rights Reserved.
  8. *
  9. * NOTICE:  All information contained herein is, and remains
  10. * the property of Adobe Systems Incorporated and its suppliers,
  11. * if any.  The intellectual and technical concepts contained
  12. * herein are proprietary to Adobe Systems Incorporated and its
  13. * suppliers and may be covered by U.S. and Foreign Patents,
  14. * patents in process, and are protected by trade secret or copyright law.
  15. * Dissemination of this information or reproduction of this material
  16. * is strictly forbidden unless prior written permission is obtained
  17. * from Adobe Systems Incorporated.
  18. *
  19. * $Id: //ols/research/cs2/ols.jsx#69 $
  20. * $DateTime: 2005/03/10 21:10:14 $
  21. * $Change: 7418 $
  22. * $Author: gscott $
  23. *
  24. **************************************************************************/
  25.  
  26. onlineservices = { };
  27.  
  28. if ( BridgeTalk.appName == "bridge" &&     app.language != "Chinese" && app.language != "Korean" )
  29. {
  30.     
  31.     $.level=0
  32.  
  33.     onlineservices.versionString = "3.0.29";
  34.  
  35.     onlineservices.logging     = 0;
  36.     onlineservices.debugMenu   = false;
  37.     onlineservices.newServices = false;
  38.     
  39.     onlineservices.longpath = "";
  40.     
  41.     onlineservices.isMac = (File.fs == "Macintosh");
  42.     onlineservices.isWin = (File.fs == "Windows");
  43.  
  44.     /*****************************************************************************
  45.      * Add menuitems
  46.      *****************************************************************************/
  47.      
  48.     onlineservices.menubarLocation0    = "after submenu/VersionCue";    // Do not localize.
  49.     onlineservices.menubarLocation     = "before FileInfo";             // Do not localize.
  50.     onlineservices.contextmenuLocation = "before Thumbnail/FileInfo";   // Do not localize.
  51.  
  52.     onlineservices.menuitemLocation    = "at the end of Tools/PhotoshopServices"; // Do not localize.
  53.  
  54.     // Find localized files
  55.     onlineservices.beginLocalize = function()
  56.     {
  57.         var pathSpec = "{STARTUP}" + "/";
  58.         pathSpec += (File.fs == "Macintosh") ? "../" : "";
  59.         pathSpec += "Resources/";
  60.         if (app.language == "Chinese")
  61.             pathSpec += "{LOCALE}";
  62.         else
  63.             pathSpec += "{LANGUAGE}";
  64.         pathSpec += (File.fs == "Macintosh") ? ".lproj/" : "/";
  65.         pathSpec += "{FILENAME}" + ".dat";
  66.         onlineservices.oldZStringPath = app.zStringPathSpecifier;
  67.         app.zStringPathSpecifier = pathSpec;
  68.     }
  69.  
  70.     onlineservices.endLocalize = function()
  71.     {
  72.         app.zStringPathSpecifier = onlineservices.oldZStringPath;
  73.     }
  74.  
  75.     onlineservices.localize = function( str )
  76.     {
  77.         onlineservices.beginLocalize();
  78.         var result = localize( str );
  79.         onlineservices.endLocalize();
  80.         return result;
  81.     }
  82.     
  83.  
  84.     // Photo Services
  85.  
  86.     onlineservices.menubar =
  87.         new MenuElement
  88.         (
  89.             "menu"
  90.         ,   onlineservices.localize("$$$/CS2/OLS/Menus/PhotoshopServices=Photoshop Services")
  91.         ,   '-' + onlineservices.menubarLocation0
  92.         ,   "Tools/PhotoshopServices"
  93.         );
  94.  
  95.     onlineservices.menubar.photoPrints =
  96.         new MenuElement
  97.         (
  98.             "command"
  99.         ,   onlineservices.localize("$$$/CS2/OLS/Menus/PhotoPrints=Photo Prints...")
  100.         ,   onlineservices.menuitemLocation
  101.         );
  102.     onlineservices.menubar.photoPrints.onSelect = function()
  103.     {
  104.         onlineservices.printOnline();
  105.     };
  106.     onlineservices.menubar.photoPrints.onDisplay = function()
  107.     {
  108.         this.enabled = onlineservices.isDocumentSelected();
  109.     };
  110.  
  111.     if ( onlineservices.newServices )
  112.     {
  113.         onlineservices.menubar.photoBooks =
  114.             new MenuElement
  115.             (
  116.                 "command"
  117.             ,   onlineservices.localize("$$$/CS2/OLS/Menus/PhotoBooks=Photo Books...")
  118.             ,   onlineservices.menuitemLocation
  119.             );
  120.         onlineservices.menubar.photoBooks.onSelect = function()
  121.         {
  122.             onlineservices.printBooks();
  123.         };
  124.         onlineservices.menubar.photoBooks.onDisplay = function()
  125.         {
  126.             this.enabled = onlineservices.isDocumentSelected();
  127.         };
  128.  
  129.         onlineservices.menubar.photoCalendars =
  130.             new MenuElement
  131.             (
  132.                 "command"
  133.             ,   onlineservices.localize("$$$/CS2/OLS/Menus/PhotoCalendars=Photo Calendars...")
  134.             ,   onlineservices.menuitemLocation
  135.             );
  136.         onlineservices.menubar.photoCalendars.onSelect = function()
  137.         {
  138.             onlineservices.printCalendars();
  139.         };
  140.         onlineservices.menubar.photoCalendars.onDisplay = function()
  141.         {
  142.             this.enabled = onlineservices.isDocumentSelected();
  143.         };
  144.  
  145.         onlineservices.menubar.photoGreetingCards =
  146.             new MenuElement
  147.             (
  148.                 "command"
  149.             ,   onlineservices.localize("$$$/CS2/OLS/Menus/PhotoGreetingCards=Photo Greeting Cards...")
  150.             ,   onlineservices.menuitemLocation
  151.             );
  152.         onlineservices.menubar.photoGreetingCards.onSelect = function()
  153.         {
  154.             onlineservices.printCards();
  155.         };
  156.         onlineservices.menubar.photoGreetingCards.onDisplay = function()
  157.         {
  158.             this.enabled = onlineservices.isDocumentSelected();
  159.         };
  160.         
  161.     } // endif ( onlineservices.newServices )
  162.  
  163.     onlineservices.menubar.photoSharing =
  164.         new MenuElement
  165.         (
  166.             "command"
  167.         ,   onlineservices.localize("$$$/CS2/OLS/Menus/PhotoSharing=Photo Sharing...")
  168.         ,   onlineservices.menuitemLocation
  169.         );
  170.     onlineservices.menubar.photoSharing.onSelect = function()
  171.     {
  172.         onlineservices.shareOnline();
  173.     };
  174.     onlineservices.menubar.photoSharing.onDisplay = function()
  175.     {
  176.         this.enabled = onlineservices.isDocumentSelected();
  177.     };
  178.  
  179.     onlineservices.menubar.chooseLocation =
  180.         new MenuElement
  181.         (
  182.             "command"
  183.         ,   onlineservices.localize("$$$/CS2/OLS/Menus/ChooseLocation=Choose Location...")
  184.         ,   '-' + onlineservices.menuitemLocation
  185.         );
  186.     onlineservices.menubar.chooseLocation.onSelect = function()
  187.     {
  188.         onlineservices.chooseLocation();
  189.     };
  190.     onlineservices.menubar.chooseLocation.onDisplay = function()
  191.     {
  192.         this.enabled = true;
  193.     };
  194.  
  195.     if ( onlineservices.debugMenu )
  196.     {
  197.         onlineservices.menubar.debugInfo =
  198.             new MenuElement
  199.             (
  200.                 "command"
  201.             ,   onlineservices.localize("$$$/CS2/OLS/Menus/DebugInfo=Debug Info...")
  202.             ,   onlineservices.menuitemLocation
  203.             );
  204.         onlineservices.menubar.debugInfo.onSelect = function()
  205.         {
  206.             onlineservices.showDebugInfo();
  207.         };
  208.     }
  209.         
  210.  
  211.     /*****************************************************************************
  212.      * Common code
  213.      *****************************************************************************/
  214.  
  215.     onlineservices.printOnline = function(thumbs)
  216.     {
  217.         if (thumbs == undefined)
  218.             thumbs = app.document.selections;
  219.             
  220.         onlineservices.begin( "job" );
  221.             onlineservices.begin( "service-spec" );
  222.                 onlineservices.set( "workflow", "print-photo" );
  223.             onlineservices.end();
  224.             onlineservices.includeDocuments( thumbs );
  225.         onlineservices.end();
  226.         onlineservices.startTask();
  227.     }
  228.  
  229.     onlineservices.shareOnline = function()
  230.     {
  231.         onlineservices.begin( "job" );
  232.             onlineservices.begin( "service-spec" );
  233.                 onlineservices.set( "workflow", "share-photo-upload" );
  234.             onlineservices.end();
  235.             onlineservices.includeDocuments( app.document.selections );
  236.         onlineservices.end();
  237.         onlineservices.startTask();
  238.     }
  239.  
  240.     onlineservices.printBooks = function()
  241.     {
  242.         onlineservices.begin( "job" );
  243.             onlineservices.begin( "service-spec" );
  244.                 onlineservices.set( "workflow", "print-creation" );
  245.                 onlineservices.begin( "creation-type-list" )
  246.                     onlineservices.set( "creation-type", "album" );
  247.                 onlineservices.end();
  248.             onlineservices.end();
  249.             onlineservices.includeDocuments( app.document.selections );
  250.         onlineservices.end();
  251.         onlineservices.startTask();
  252.     }
  253.  
  254.     onlineservices.printCards = function()
  255.     {
  256.         onlineservices.begin( "job" );
  257.             onlineservices.begin( "service-spec" );
  258.                 onlineservices.set( "workflow", "print-creation" );
  259.                 onlineservices.begin( "creation-type-list" )
  260.                     onlineservices.set( "creation-type", "postcard" );
  261.                 onlineservices.end();
  262.             onlineservices.end();
  263.             onlineservices.includeDocuments( app.document.selections );
  264.         onlineservices.end();
  265.         onlineservices.startTask();
  266.     }
  267.  
  268.     onlineservices.printCalendars = function()
  269.     {
  270.         onlineservices.begin( "job" );
  271.             onlineservices.begin( "service-spec" );
  272.                 onlineservices.set( "workflow", "print-creation" );
  273.                 onlineservices.begin( "creation-type-list" )
  274.                     onlineservices.set( "creation-type", "calendar" );
  275.                 onlineservices.end();
  276.             onlineservices.end();
  277.             onlineservices.includeDocuments( app.document.selections );
  278.         onlineservices.end();
  279.         onlineservices.startTask();
  280.     }
  281.  
  282.     onlineservices.chooseLocation = function()
  283.     {
  284.         onlineservices.begin( "job" );
  285.             onlineservices.begin( "service-spec" );
  286.                 onlineservices.set( "workflow", "preferences" );
  287.             onlineservices.end();
  288.         onlineservices.end();
  289.         onlineservices.startTask();
  290.     }
  291.     
  292.     onlineservices.begin = function( name )
  293.     {
  294.         app.initializeOpera();   
  295.         onlineservices.loadLib();
  296.         onlineservices.lib.begin( name );
  297.     }
  298.  
  299.     onlineservices.end = function()
  300.     {
  301.         onlineservices.loadLib();
  302.         onlineservices.lib.end();
  303.     }
  304.  
  305.     onlineservices.set = function( name, value )
  306.     {
  307.         onlineservices.loadLib();
  308.         onlineservices.lib.set( name, value );
  309.     }
  310.     
  311.     onlineservices.isDocumentSelected = function()
  312.     {
  313.         return app.document.selections.length > 0;
  314.     }
  315.  
  316.     onlineservices.log = function(str)
  317.     {
  318.         app.console( "[OnlineServices] " + str + "\n" );
  319.     };
  320.  
  321.     onlineservices.dumpObj = function( prefix, obj )
  322.     {
  323.         var e = "";
  324.         for (i in obj)
  325.         {
  326.             if (e == "")
  327.             {
  328.                 e += "{ ";
  329.             }
  330.             else
  331.             {
  332.                 e += ", ";
  333.             }
  334.             e += i + ":" + obj[i];
  335.         }
  336.         e += " }";
  337.         onlineservices.log(prefix + e);
  338.     }
  339.  
  340.     onlineservices.createUpdateServicesView = function()
  341.     {
  342.         var v = new Window( 'palette' );
  343.         v.orientation = 'column';
  344.         v.alignChildren = 'center';
  345.  
  346.         v.description  = v.add( 'statictext' );
  347.         v.description.text = onlineservices.localize( "$$$/CS2/OLS/ServiceListUpdate/ProgressMessage=Updating online service list..." );
  348.  
  349.         v.cancelButton = v.add( 'button' );
  350.         v.cancelButton.alignment = 'right';
  351.         v.cancelButton.text = onlineservices.localize( "$$$/CS2/OLS/SessionManager/CancelButton=Cancel" );
  352.  
  353.         v.layout.layout( true );
  354.                
  355.         v.cancelButton.onClick = function()
  356.         {
  357.             onlineservices.lib.terminateSession();
  358.         }
  359.  
  360.         v.onClose = function()
  361.         {
  362.             onlineservices.lib.terminateSession();
  363.         }
  364.         
  365.         return v;
  366.     }
  367.  
  368.     onlineservices.showUpdateServicesView = function()
  369.     {
  370.         var v = onlineservices.updateServicesView;
  371.  
  372.         if ( v == undefined )
  373.         {
  374.             v = onlineservices.updateServicesView = onlineservices.createUpdateServicesView();
  375.         }
  376.  
  377.         v.show();
  378.     }
  379.  
  380.     onlineservices.hideUpdateServicesView = function()
  381.     {
  382.         var v = onlineservices.updateServicesView;
  383.         if ( v != undefined )
  384.         {
  385.             v.hide();
  386.         }
  387.     }
  388.     
  389.     onlineservices.createProgressView = function( description, percent, detail )
  390.     {
  391.         if (onlineservices.progressView)
  392.         {
  393.             onlineservices.progressView.description.text = description;
  394.             onlineservices.progressView.progress.value = percent;
  395.             onlineservices.progressView.detail.text = detail;
  396.             onlineservices.progressView.layout.layout(true);
  397.             onlineservices.progressView.show();
  398.         }
  399.         else
  400.         {
  401.             var v = new Window( 'palette' );
  402.             v.orientation            = 'column';
  403.             v.alignChildren          = 'fill';
  404.     
  405.             v.description            = v.add( 'statictext' );
  406.             v.description.text         = onlineservices.longpath;
  407.         
  408.             v.progress               = v.add( 'progressbar' );
  409.             v.progress.preferredSize = { width:300, height:20 };
  410.             v.progress.value         = percent;
  411.  
  412.             v.detail                 = v.add( 'statictext' );
  413.             v.detail.justify         = 'center';
  414.             v.detail.text            = detail;
  415.         
  416.             v.cancelButton = v.add( 'button' );
  417.             v.cancelButton.alignment = 'right';
  418.             v.cancelButton.text = onlineservices.localize( "$$$/CS2/OLS/SessionManager/CancelButton=Cancel" );
  419.  
  420.             v.center();
  421.             v.show();
  422.         
  423.             v.cancelButton.onClick = function()
  424.             {
  425.                 onlineservices.lib.terminateSession();
  426.             }
  427.  
  428.             v.onClose = function()
  429.             {
  430.                 onlineservices.lib.terminateSession();
  431.             }
  432.             
  433.             onlineservices.progressView = v;
  434.             v.description.text       = description;
  435.         }
  436.     }
  437.  
  438.     onlineservices.updateProgressView = function( description, bytesCompleted, bytesTotal )
  439.     {
  440.         if ( bytesCompleted != bytesTotal )
  441.         {
  442.             var descriptionDecoded = unescape( description );
  443.             var detail = bytesCompleted.toString() + " / " + bytesTotal.toString(); // FIXME: Zstring needed;
  444.             var percent;
  445.             
  446.             if ( bytesCompleted == 0 )
  447.             {
  448.                 percent = 0;
  449.             }
  450.             else if ( bytesCompleted >= bytesTotal )
  451.             {
  452.                 percent = 100;
  453.             }
  454.             else
  455.             {
  456.                 percent = Math.ceil( bytesCompleted / bytesTotal * 100 );
  457.             }
  458.            
  459.             if ( onlineservices.progressView )
  460.             {
  461.                 if ( onlineservices.progressView.description.text != descriptionDecoded )
  462.                 {
  463.                     onlineservices.createProgressView( descriptionDecoded, percent, detail );
  464.                 }
  465.                 else
  466.                 {
  467.                     onlineservices.progressView.progress.value = percent;
  468.                     onlineservices.progressView.detail.text = detail;
  469.                 }
  470.             }
  471.             else
  472.             {
  473.                 onlineservices.createProgressView( descriptionDecoded, percent, detail );
  474.             }
  475.         }
  476.         else
  477.         {
  478.             if ( onlineservices.progressView )
  479.             {
  480.                 onlineservices.progressView.hide();
  481.             }
  482.         }
  483.     }
  484.  
  485.    onlineservices.hideProgressView = function()
  486.     {
  487.         if ( onlineservices.progressView )
  488.         {
  489.             onlineservices.progressView.hide();
  490.         }
  491.     }
  492.     
  493.     onlineservices.finishProgressView = function()
  494.     {
  495.         if ( onlineservices.progressView )
  496.         {
  497.             onlineservices.progressView.close();
  498.             onlineservices.progressView = undefined;
  499.         }
  500.     }
  501.  
  502.     onlineservices.loadLocale = function()
  503.     {
  504.         if ( onlineservices.lib )
  505.         {
  506.             onlineservices.lib.set("app_locale", app.locale);
  507.         }
  508.     }
  509.  
  510.     onlineservices.bringAppToFront = function()
  511.     {
  512.         BridgeTalk.bringToFront("bridge");
  513.     }
  514.  
  515.     onlineservices.getLibFilename = function()
  516.     {
  517.         var libFilename;
  518.         if ( onlineservices.isWin )
  519.         {
  520.             libFilename = "ols.dll";
  521.         }
  522.         else // if ( onlineservices.isMac )
  523.         {
  524.             libFilename = "ols.bundle";
  525.         }
  526.         return libFilename;
  527.  
  528.     }
  529.     
  530.     onlineservices.getLibPath = function()
  531.     {
  532.         var libFilename = onlineservices.getLibFilename();
  533.         var libPath;
  534.         if ( onlineservices.isWin )
  535.         {
  536.             libPath = Folder.startup + "/" + libFilename;
  537.         }
  538.         else // if ( onlineservices.isMac )
  539.         {
  540.             libPath = Folder.startup.fsName + "/../../../Plug-ins/" + libFilename;
  541.         }
  542.         return libPath;
  543.     }
  544.  
  545.     onlineservices.loadLib = function()
  546.     {
  547.         if ( onlineservices.lib == undefined )
  548.         {
  549.             var libPath = onlineservices.getLibPath();
  550.             var libFileObj = new File( libPath );
  551.             if ( libFileObj.exists )
  552.             {
  553.                 onlineservices.lib = new ExternalObject( "lib:" + libPath );
  554.                 onlineservices.lib.setLogging( onlineservices.logging );
  555.                 onlineservices.restoreProperties();
  556.                 onlineservices.loadLocale();
  557.             }
  558.             else
  559.             {
  560.                 Window.alert( "OLS library not found: " + libPath );
  561.             }
  562.         }
  563.     }
  564.  
  565.     onlineservices.restoreProperties = function()
  566.     {
  567.         if ( app.preferences.onlineservicesPropertyKeysA  == undefined
  568.           || app.preferences.onlineservicesPropertyKeysB  == undefined
  569.           || app.preferences.onlineservicesPropertyValues == undefined )
  570.         {
  571.             return;
  572.         }
  573.         
  574.         var keysA  = eval( app.preferences.onlineservicesPropertyKeysA );
  575.         var keysB  = eval( app.preferences.onlineservicesPropertyKeysB );
  576.         var values = eval( app.preferences.onlineservicesPropertyValues );
  577.  
  578.         if ( keysA.length != keysB.length || keysB.length != values.length )
  579.         {
  580.             return;
  581.         }
  582.         
  583.         onlineservices.begin( "cs2-ols-properties" ); // Do not localize.
  584.         
  585.         for ( var i in keysA )
  586.         {
  587.             onlineservices.begin( "cs2-ols-property" ); // Do not localize.
  588.                 onlineservices.set( "key-a", unescape( keysA[i] ) ); // Do not localize.
  589.                 onlineservices.set( "key-b", unescape( keysB[i] ) ); // Do not localize.
  590.                 onlineservices.set( "value", unescape( values[i] ) ); // Do not localize.
  591.             onlineservices.end();
  592.         }
  593.  
  594.         onlineservices.end();
  595.     }
  596.    
  597.     onlineservices.beginProperties = function()
  598.     {
  599.         onlineservices.propertyKeysA  = new Array;
  600.         onlineservices.propertyKeysB  = new Array;
  601.         onlineservices.propertyValues = new Array;
  602.     }
  603.  
  604.     onlineservices.setProperty = function( keyA, keyB, value )
  605.     {
  606.         onlineservices.propertyKeysA.push(  escape( keyA ) );
  607.         onlineservices.propertyKeysB.push(  escape( keyB ) );
  608.         onlineservices.propertyValues.push( escape( value ) );
  609.     }
  610.  
  611.     onlineservices.endProperties = function()
  612.     {
  613.         app.preferences.onlineservicesPropertyKeysA  = onlineservices.propertyKeysA.toSource();
  614.         app.preferences.onlineservicesPropertyKeysB  = onlineservices.propertyKeysB.toSource();
  615.         app.preferences.onlineservicesPropertyValues = onlineservices.propertyValues.toSource();
  616.     }
  617.     
  618.     onlineservices.pumpOls = function()
  619.     {
  620.         if ( onlineservices.lib.pumpOLS() )
  621.         {
  622.             onlineservices.processMessages();
  623.         }
  624.     }
  625.  
  626.     onlineservices.processMessages = function()
  627.     {
  628.         while ( onlineservices.processMessage() )
  629.         {
  630.         }
  631.     }
  632.     
  633.     onlineservices.processMessage = function()
  634.     {
  635.         var msg = onlineservices.lib.getMessage();
  636.         if ( typeof( msg ) == "script" )
  637.         {
  638.             var delay  = 1; // In milliseconds.
  639.             var repeat = false;
  640.             app.scheduleTask( script, delay, repeat );
  641.             return true;
  642.         }
  643.         else
  644.         {
  645.             return false;
  646.         }
  647.     }
  648.     
  649.     onlineservices.startTask = function()
  650.     {
  651.         if ( onlineservices.taskId == undefined )
  652.         {
  653.             var script = 'onlineservices.pumpOls();';
  654.             var delay  = 100; // In milliseconds.
  655.             var repeat = true;
  656.             onlineservices.taskId  = app.scheduleTask( script, delay, repeat );
  657.         }
  658.     }
  659.  
  660.     onlineservices.stopTask = function()
  661.     {
  662.         if ( onlineservices.taskId != undefined )
  663.         {
  664.             var repeat = true;
  665.             app.cancelTask( onlineservices.taskId, repeat );
  666.             onlineservices.taskId = undefined;
  667.         }
  668.     }
  669.  
  670.     onlineservices.concat_paths = function( path1, path2 )
  671.     {
  672.         var separator;
  673.         if ( onlineservices.isWin )
  674.         {
  675.             separator = '\\';
  676.         }
  677.         else // if ( onlineservices.isMac )
  678.         {
  679.             separator = '/';
  680.         }
  681.         // FIXME: Can't blindly insert a separator.
  682.         return path1 + '\\' + path2;
  683.     }
  684.  
  685.     onlineservices.includeDocuments = function( documents )
  686.     {
  687.         onlineservices.gotNonJPEG = false;
  688.         onlineservices.longpath = "";
  689.         
  690.         onlineservices.lib.begin( "file-list" );
  691.  
  692.             var thePath = app.document.thumbnail.path;
  693.             for (i=0; i<documents.length; i++)
  694.             {
  695.                 var thumbnail = documents[i];
  696.                 if ( !thumbnail.container )
  697.                 {
  698.                     app.preflightFiles( Array( thumbnail.path ) );
  699.                     onlineservices.includeDocument( thumbnail );
  700.                 }
  701.             }
  702.             
  703.         onlineservices.lib.end();
  704.         
  705.         if (onlineservices.gotNonJPEG)
  706.             Window.alert( onlineservices.localize("$$$/CS2/OLS/ErrorHandler/UseJPEG=Files selected for uploading must be in JPEG format.") );
  707.     }
  708.  
  709.     onlineservices.twoDigits = function( n )
  710.     {
  711.         if ( n < 10 )
  712.         {
  713.             return '0'+n;
  714.         }
  715.         else
  716.         {
  717.             return n;
  718.         }
  719.     }
  720.     
  721.     onlineservices.formatDate = function( d )
  722.     {
  723.         return d.getUTCFullYear()
  724.             + '-' + onlineservices.twoDigits( 1 + d.getUTCMonth() )
  725.             + '-' + onlineservices.twoDigits( d.getUTCDate() )
  726.             + '_' + onlineservices.twoDigits( d.getUTCHours() )
  727.             + ':' + onlineservices.twoDigits( d.getUTCMinutes() )
  728.             + ':' + onlineservices.twoDigits( d.getUTCSeconds() );
  729.     }
  730.     
  731.     onlineservices.hashString = function( str )
  732.     {
  733.         var result = 1;
  734.         for ( var i = 0; i < str.length; ++i )
  735.         {
  736.             result = ( 10*result + str.charCodeAt( i ) ) % 0xFFFFFFFF;
  737.         }
  738.         return result;
  739.     }  
  740.  
  741.     /*
  742.        Excerpted from OLSMessageExchangeConstants.h (internal):
  743.        
  744.         #define kOLSName_File                 "file"
  745.         #define kOLSName_File_Id              "id"
  746.         #define kOLSName_File_Type            "type"
  747.         #define kOLSName_File_Name            "name"
  748.         #define kOLSName_File_Caption         "caption"
  749.         #define kOLSName_File_Url             "url"
  750.         #define kOLSName_File_Size            "size"
  751.         #define kOLSName_File_Created         "created"
  752.         #define kOLSName_File_Modified        "modified"
  753.         #define kOLSName_File_Version         "version"
  754.         #define kOLSName_File_Xmp             "xmp"
  755.  
  756.         #define kOLSName_ImageInfo            "image-info"
  757.         #define kOLSName_ImageInfo_Width      "width"
  758.         #define kOLSName_ImageInfo_Height     "height"
  759.         #define kOLSName_ImageInfo_Resolution "resolution"
  760.         #define kOLSName_ImageInfo_Rotation   "rotation"
  761.  
  762.         #define kOLSName_Color                "color"
  763.         #define kOLSName_Color_Space          "space"
  764.         #define kOLSName_Color_BitsPerChannel "bits-per-channel"
  765.         #define kOLSName_Color_Profile        "profile"
  766.      */
  767.     onlineservices.includeDocument = function( thumbnail )
  768.     {
  769.         var m = thumbnail.metadata;
  770.         var spec = thumbnail.spec;
  771.         var d;
  772.         
  773.         if ( thumbnail.mimeType == "image/jpeg")    //     Do not localize
  774.         {
  775.             onlineservices.lib.begin( "file" );
  776.             
  777.                 var id = onlineservices.hashString( spec.fsName ).toString( 16 );
  778.                 if ( spec.modified != undefined )
  779.                 {
  780.                     id = id + ':' + onlineservices.formatDate( spec.modified );
  781.                 }
  782.                 
  783.                 onlineservices.lib.set( "id", id ); 
  784.                 onlineservices.lib.set( "name", unescape(spec.name) );
  785.                 onlineservices.lib.set( "fullpath", spec.fsName );
  786.                 onlineservices.lib.set( "escaped-name", escape( spec.fsName ) );
  787.                 onlineservices.lib.set( "encoded-name", File.encode( spec.fsName ) );
  788.                 onlineservices.lib.set( "size", spec.length.toString() ); 
  789.                 onlineservices.lib.set( "type", thumbnail.mimeType );
  790.                 d = spec.created;
  791.                 if ( d != undefined )
  792.                 {
  793.                     onlineservices.lib.set( "created", onlineservices.formatDate( d ) );
  794.                 }
  795.                 d = spec.modified;
  796.                 if ( d != undefined )
  797.                 {
  798.                     onlineservices.lib.set( "modified", onlineservices.formatDate( d ) );
  799.                 }
  800.  
  801.                 onlineservices.lib.begin( "image-info" );
  802.  
  803.                     onlineservices.lib.set( "dimensions", m.FileDimensions );
  804.                     onlineservices.lib.set( "resolution", m.FileResolution );
  805.                     
  806.                        onlineservices.lib.begin( "color" );
  807.                    
  808.                         onlineservices.lib.set( "space", m.FileColorMode );
  809.                         onlineservices.lib.set( "bits-per-channel", m.FileBitDepth );
  810.                           onlineservices.lib.set( "profile", m.FileColorProfile );
  811.  
  812.                        onlineservices.lib.end();
  813.  
  814.                 onlineservices.lib.end();
  815.                 
  816.             onlineservices.lib.end();
  817.             
  818.             if (onlineservices.longpath.length < spec.fsName.length)
  819.             {
  820.                 onlineservices.longpath = spec.fsName;
  821.             }
  822.         }
  823.         else
  824.         {
  825.             onlineservices.gotNonJPEG = true;
  826.         }
  827.     }
  828.    
  829.     onlineservices.showDebugInfo = function()
  830.     {
  831.         var jsxVersion   = "ols.jsx version: " + onlineservices.versionString;
  832.         var libFilename  = onlineservices.getLibFilename();
  833.         var libVersion   = libFilename + " version: ";
  834.         var libBuildDate = libFilename + " build date: ";
  835.         
  836.         onlineservices.loadLib();
  837.         if ( onlineservices.lib )
  838.         {
  839.             libVersion   += onlineservices.lib.getOLSCS2Version();
  840.             libBuildDate += onlineservices.lib.getOLSCS2BuildDate();
  841.         }
  842.         else
  843.         {
  844.             libVersion   += "lib not found";
  845.             libBuildDate += "lib not found";
  846.         }
  847.         Window.alert( jsxVersion + '\n' + libVersion + '\n' + libBuildDate );
  848.     }
  849.     
  850.  
  851.     /*****************************************************************************
  852.      * onlineservices.core
  853.      *****************************************************************************/
  854.  
  855.     onlineservices.core = { };
  856.  
  857.     onlineservices.core.eventHandler = function( event )
  858.     {
  859.         var result = { handled: false };
  860.         var target = event.object
  861.  
  862.     //    onlineservices.dumpObj("Event: ", event);
  863.  
  864.         if (target instanceof Thumbnail)
  865.         {
  866.     //        return onlineservices.core.doThumbEvent(event);
  867.         }
  868.         else if (target instanceof Document)
  869.         {
  870.     //        return onlineservices.core.doDocEvent(event)
  871.         }
  872.         else if (target instanceof App)
  873.         {
  874.     //        return onlineservices.core.doAppEvent(event);
  875.         }
  876.  
  877.         return result;
  878.     }
  879.  
  880.  
  881.     onlineservices.initialize = function()
  882.     {
  883.     //    install_visiturl_callback_later();
  884.  
  885.         app.eventHandlers.push( { handler: onlineservices.core.eventHandler } );
  886.     }
  887.  
  888.  
  889.     /*****************************************************************************
  890.      * Code to execute at the time this script is loaded.
  891.      *****************************************************************************/
  892.  
  893.     onlineservices.initialize();
  894.  
  895. } // Endif ( BridgeTalk.appName == "bridge" )
  896. else
  897. {
  898.     // ***************
  899.     // Point App APIs
  900.     // ***************
  901.  
  902. };
  903.  
  904. /*****************************************************************************
  905.  * End
  906.  *****************************************************************************/
  907.